package znbkTopicType.content;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import com.example.lancooznbk.R;

import org.apache.commons.lang3.StringEscapeUtils;

import lancooControl.Control;
import znbkTopicType.WrapBaseAdapter;
import znbkTestPaperInfor.ZnbkPaperDef;

import static znbkTestPaperCtfd.activity.WrongTopicTutoringPaperActivity.mEntityCtfd;
import static znbkTestPaperLstjt.activity.HistoryRecommendQuesPaperActivity.mEntityLstjt;
import static znbkTestPaperNtxl.activity.TrainingDifficultProblemsPaperActivity.mEntityNtxl;
import static znbkTestPaperRdqh.activity.WeekAscensionPaperActivity.mEntityRdqh;
import static znbkTestPaperXtfx.activity.SystemReviewPaperActivity.mEntityXtfx;

/**
 * Created by Administrator on 2018\2\26 0026.
 */

public class ZnbkContentPptAdapter extends WrapBaseAdapter {

    private LayoutInflater mInflater;
    private Context mContext;
    //当前试题数量
    private int ItemCount;
    //当前试题在当前试卷的ID
    private int PaperID;
    private int ModelFrom;//试卷来源


    private ViewHolder holder = null;
    public class ViewHolder{
        WebView WvTheme;
        public ViewHolder(View convertView) {
            WvTheme = (WebView) convertView.findViewById(R.id.wv_theme);
        }
    }

    private String SubChildAsk;//获取答题题干（匹配题）
    private int totalItemCount;//选择题个数

    public ZnbkContentPptAdapter(Context context, int itemCount, int paperID, int modelFrom) {
        mInflater = LayoutInflater.from(context);
        this.mContext = context;
        this.ItemCount = itemCount;
        this.PaperID = paperID;
        this.ModelFrom =modelFrom;
    }

    @Override
    public int getCount() {
        return ItemCount;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.znbk_adapter_content_ppt_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        /*
        * 获取试题相关信息
        * */
        getQuesInfor();

        /*
        * 显示大题题干
        * */
        showQuesInfor();

        return convertView;
    }


    /*
   * 获取作文题用户相关信息
   * */
    private String GenreName = "";
    private String subChildAsk = "";
    private String subChildAnswer = "";
    private String subChildStuAnswer = "";
    public static int status = -1;
    public static int TotalItemCount = -1;
    public static int sumOption;//选项的个数
    public static String[] optionIndex;//选项号
    public static String[] optionContent;//选项内容对应的文字
    public static String[] smallSubChileAnswer;
    public static String[] smallSubChileStuAnswer;
    public static String analysis;
    /*
    * 获取试题信息
    * */
    private void getQuesInfor(){

        if(ModelFrom== ZnbkPaperDef.FROM_TRAINING_DIFFICULT_PROBLEMS) {
            status = mEntityNtxl.getAnswerState();
            totalItemCount = Control.backSum(mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
            SubChildAsk = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

              /*
            * 正确答案：subChildAnswer
            * 小题数目：TotalItemCount
            * 小题答案：smallSubChileAnswer[i]
            * */
            subChildAnswer = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
            TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
            smallSubChileAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
            }

                /*
                * 选项个数：sumOption
                * 选项题号：optionIndex[i]
                * 选项内容：optionContent[i]
                * */
            sumOption = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().size();
            optionIndex = new String[sumOption];
            optionContent = new String[sumOption];
            for (int i = 0; i < sumOption; i++) {
                optionIndex[i] = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                optionContent[i] = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
            }

             /*
            * 学生答案：subChildStuAnswer
            * 小题学生答案：smallSubChileStuAnswer[i]
            * */
            subChildStuAnswer = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();
            smallSubChileStuAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                if(subChildStuAnswer.equals("")){
                    smallSubChileStuAnswer[i] = "";
                }else {
                    smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                }
                Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
            }

                /*
                * 题材类型：ResTypeName
                * */
            GenreName =  mEntityNtxl.getTKQue().getGenreName();

                /*
                * 文本内容：词汇填空
                * */
            subChildAsk = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

            String arraySubChildAsk[] = new String[TotalItemCount + 1];
            String subChildAskAll = "";
            for (int i = 0; i < TotalItemCount + 1; i++) {
                arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                if (i < TotalItemCount) {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                } else {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                }
            }
            subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

            /*
            * 答案解析：analysis
            **/
            analysis = mEntityNtxl.getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();

        }else if(ModelFrom ==ZnbkPaperDef.FROM_SYSTEM_REVIEW){
            status = mEntityXtfx.getModelSinglePaperInfo().getModelPaperInfo().getAnswerState();
            totalItemCount = Control.backSum(mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
            SubChildAsk = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAsk();


            /*
            * 正确答案：subChildAnswer
            * 小题数目：TotalItemCount
            * 小题答案：smallSubChileAnswer[i]
            * */
            subChildAnswer = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
            TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
            smallSubChileAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
            }

              /*
            * 学生答案：subChildStuAnswer
            * 小题学生答案：smallSubChileStuAnswer[i]
            * */
            subChildStuAnswer = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();

            smallSubChileStuAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                if(subChildStuAnswer.equals("")){
                    smallSubChileStuAnswer[i] = "";
                }else {
                    smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                }
                Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
            }


            /*
            * 选项个数：sumOption
            * 选项题号：optionIndex[i]
            * 选项内容：optionContent[i]
            * */
            sumOption = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().size();
            optionIndex = new String[sumOption];
            optionContent = new String[sumOption];
            for (int i = 0; i < sumOption; i++) {
                optionIndex[i] = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                optionContent[i] = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
            }

            /*
            * 题材类型：ResTypeName
            * */
            GenreName =  mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getGenreName();

            /*
            * 文本内容：词汇填空
            * */
            subChildAsk = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

            String arraySubChildAsk[] = new String[TotalItemCount + 1];
            String subChildAskAll = "";
            for (int i = 0; i < TotalItemCount + 1; i++) {
                arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                if (i < TotalItemCount) {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                } else {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                }
            }
            subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

            /*
            * 答案解析：analysis
            **/
            analysis = mEntityXtfx.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();

        }else if(ModelFrom ==ZnbkPaperDef.FROM_WEEK_ASCENSION){
            status = mEntityRdqh.getModelSinglePaperInfo().getModelPaperInfo().getAnswerState();
            totalItemCount = Control.backSum(mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
            SubChildAsk = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAsk();


            /*
            * 正确答案：subChildAnswer
            * 小题数目：TotalItemCount
            * 小题答案：smallSubChileAnswer[i]
            * */
            subChildAnswer = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
            TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
            smallSubChileAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
            }

              /*
            * 学生答案：subChildStuAnswer
            * 小题学生答案：smallSubChileStuAnswer[i]
            * */
            subChildStuAnswer = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();

            smallSubChileStuAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                if(subChildStuAnswer.equals("")){
                    smallSubChileStuAnswer[i] = "";
                }else {
                    smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                }
                Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
            }


            /*
            * 选项个数：sumOption
            * 选项题号：optionIndex[i]
            * 选项内容：optionContent[i]
            * */
            sumOption = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().size();
            optionIndex = new String[sumOption];
            optionContent = new String[sumOption];
            for (int i = 0; i < sumOption; i++) {
                optionIndex[i] = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                optionContent[i] = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
            }

            /*
            * 题材类型：ResTypeName
            * */
            GenreName =  mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getGenreName();

            /*
            * 文本内容：词汇填空
            * */
            subChildAsk = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

            String arraySubChildAsk[] = new String[TotalItemCount + 1];
            String subChildAskAll = "";
            for (int i = 0; i < TotalItemCount + 1; i++) {
                arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                if (i < TotalItemCount) {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                } else {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                }
            }
            subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

            /*
            * 答案解析：analysis
            **/
            analysis = mEntityRdqh.getModelSinglePaperInfo().getModelTKQueList().get(PaperID).getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();

        }else if(ModelFrom==ZnbkPaperDef.FROM_WRONG_TOPIC_TUTORING){

            int anotherPaperID = -1;
            if(PaperID==0){
                status = 3;
                totalItemCount = Control.backSum(mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
                SubChildAsk = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildAsk();

                /*
                * 正确答案：subChildAnswer
                * 小题数目：TotalItemCount
                * 小题答案：smallSubChileAnswer[i]
                * */
                subChildAnswer = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildAnswer();
                TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
                smallSubChileAnswer = new String[TotalItemCount];
                for(int i=0;i<TotalItemCount;i++){
                    smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                    Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
                }

                /*
                * 学生答案：subChildStuAnswer
                * 小题学生答案：smallSubChileStuAnswer[i]
                * */
                subChildStuAnswer = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildStuAnswer();

                smallSubChileStuAnswer = new String[TotalItemCount];
                for(int i=0;i<TotalItemCount;i++){
                    if(subChildStuAnswer.equals("")){
                        smallSubChileStuAnswer[i] = "";
                    }else {
                        smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                    }
                    Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
                }


                /*
                * 选项个数：sumOption
                * 选项题号：optionIndex[i]
                * 选项内容：optionContent[i]
                * */
                sumOption = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildOptionList().size();
                optionIndex = new String[sumOption];
                optionContent = new String[sumOption];
                for (int i = 0; i < sumOption; i++) {
                    optionIndex[i] = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                    optionContent[i] =mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
                }

                /*
                * 题材类型：ResTypeName
                * */
                GenreName =  mEntityCtfd.getPrimitiveQues().getTKQue().getGenreName();

                /*
                * 文本内容：词汇填空
                * */
                subChildAsk = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildAsk();

                String arraySubChildAsk[] = new String[TotalItemCount + 1];
                String subChildAskAll = "";
                for (int i = 0; i < TotalItemCount + 1; i++) {
                    arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                    if (i < TotalItemCount) {
                        subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                    } else {
                        subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                    }
                }
                subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

                /*
                * 答案解析：analysis
                **/
                analysis = mEntityCtfd.getPrimitiveQues().getTKQue().getChildList().get(PaperID).getSubChildList().get(0).getSubChildAnalyze();

            }else if(PaperID==1){

                anotherPaperID = PaperID-1;
                if(mEntityCtfd.getClassicalQues()!=null){
                    status = 3;
                    totalItemCount = Control.backSum(mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
                    SubChildAsk = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildAsk();

                /*
                * 正确答案：subChildAnswer
                * 小题数目：TotalItemCount
                * 小题答案：smallSubChileAnswer[i]
                * */
                    subChildAnswer = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildAnswer();
                    TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
                    smallSubChileAnswer = new String[TotalItemCount];
                    for(int i=0;i<TotalItemCount;i++){
                        smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                        Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
                    }

                /*
                * 学生答案：subChildStuAnswer
                * 小题学生答案：smallSubChileStuAnswer[i]
                * */
                    subChildStuAnswer = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildStuAnswer();

                    smallSubChileStuAnswer = new String[TotalItemCount];
                    for(int i=0;i<TotalItemCount;i++){
                        if(subChildStuAnswer.equals("")){
                            smallSubChileStuAnswer[i] = "";
                        }else {
                            smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                        }
                        Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
                    }


                /*
                * 选项个数：sumOption
                * 选项题号：optionIndex[i]
                * 选项内容：optionContent[i]
                * */
                    sumOption = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildOptionList().size();
                    optionIndex = new String[sumOption];
                    optionContent = new String[sumOption];
                    for (int i = 0; i < sumOption; i++) {
                        optionIndex[i] = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                        optionContent[i] =mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
                    }

                /*
                * 题材类型：ResTypeName
                * */
                    GenreName =  mEntityCtfd.getClassicalQues().getTKQue().getGenreName();

                /*
                * 文本内容：词汇填空
                * */
                    subChildAsk = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildAsk();

                    String arraySubChildAsk[] = new String[TotalItemCount + 1];
                    String subChildAskAll = "";
                    for (int i = 0; i < TotalItemCount + 1; i++) {
                        arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                        if (i < TotalItemCount) {
                            subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                        } else {
                            subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                        }
                    }
                    subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

                /*
                * 答案解析：analysis
                **/
                    analysis = mEntityCtfd.getClassicalQues().getTKQue().getChildList().get(anotherPaperID).getSubChildList().get(0).getSubChildAnalyze();

                }else{
                    status = mEntityCtfd.getRecQues().get(0).getAnswerState();
                    totalItemCount = Control.backSum(mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
                    SubChildAsk = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

                /*
                * 正确答案：subChildAnswer
                * 小题数目：TotalItemCount
                * 小题答案：smallSubChileAnswer[i]
                * */
                    subChildAnswer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
                    TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
                    smallSubChileAnswer = new String[TotalItemCount];
                    for(int i=0;i<TotalItemCount;i++){
                        smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                        Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
                    }

                /*
                * 学生答案：subChildStuAnswer
                * 小题学生答案：smallSubChileStuAnswer[i]
                * */
                    subChildStuAnswer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();

                    smallSubChileStuAnswer = new String[TotalItemCount];
                    for(int i=0;i<TotalItemCount;i++){
                        if(subChildStuAnswer.equals("")){
                            smallSubChileStuAnswer[i] = "";
                        }else {
                            smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                        }
                        Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
                    }


                /*
                * 选项个数：sumOption
                * 选项题号：optionIndex[i]
                * 选项内容：optionContent[i]
                * */
                    sumOption = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().size();
                    optionIndex = new String[sumOption];
                    optionContent = new String[sumOption];
                    for (int i = 0; i < sumOption; i++) {
                        optionIndex[i] = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                        optionContent[i] =mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
                    }

                /*
                * 题材类型：ResTypeName
                * */
                    GenreName =  mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getGenreName();

                /*
                * 文本内容：词汇填空
                * */
                    subChildAsk = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

                    String arraySubChildAsk[] = new String[TotalItemCount + 1];
                    String subChildAskAll = "";
                    for (int i = 0; i < TotalItemCount + 1; i++) {
                        arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                        if (i < TotalItemCount) {
                            subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                        } else {
                            subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                        }
                    }
                    subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

                /*
                * 答案解析：analysis
                **/
                    analysis = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();

                }
            }else{
                status = mEntityCtfd.getRecQues().get(0).getAnswerState();
                if(mEntityCtfd.getClassicalQues()!=null){
                    anotherPaperID = PaperID-2;
                }else{
                    anotherPaperID = PaperID-1;
                }
                totalItemCount = Control.backSum(mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
                SubChildAsk = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

                /*
                * 正确答案：subChildAnswer
                * 小题数目：TotalItemCount
                * 小题答案：smallSubChileAnswer[i]
                * */
                subChildAnswer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
                TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
                smallSubChileAnswer = new String[TotalItemCount];
                for(int i=0;i<TotalItemCount;i++){
                    smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                    Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
                }

                /*
                * 学生答案：subChildStuAnswer
                * 小题学生答案：smallSubChileStuAnswer[i]
                * */
                subChildStuAnswer = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();

                smallSubChileStuAnswer = new String[TotalItemCount];
                for(int i=0;i<TotalItemCount;i++){
                    if(subChildStuAnswer.equals("")){
                        smallSubChileStuAnswer[i] = "";
                    }else {
                        smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                    }
                    Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
                }


                /*
                * 选项个数：sumOption
                * 选项题号：optionIndex[i]
                * 选项内容：optionContent[i]
                * */
                sumOption = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().size();
                optionIndex = new String[sumOption];
                optionContent = new String[sumOption];
                for (int i = 0; i < sumOption; i++) {
                    optionIndex[i] = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                    optionContent[i] =mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
                }

                /*
                * 题材类型：ResTypeName
                * */
                GenreName =  mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getGenreName();

                /*
                * 文本内容：词汇填空
                * */
                subChildAsk = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

                String arraySubChildAsk[] = new String[TotalItemCount + 1];
                String subChildAskAll = "";
                for (int i = 0; i < TotalItemCount + 1; i++) {
                    arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                    if (i < TotalItemCount) {
                        subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                    } else {
                        subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                    }
                }
                subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

                /*
                * 答案解析：analysis
                **/
                analysis = mEntityCtfd.getRecQues().get(anotherPaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();

            }
        }else if(ModelFrom ==ZnbkPaperDef.FROM_HISTORY_RECOMMEND_QUESTION){
            status = 3;
            totalItemCount = Control.backSum(mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer(),"$、")+1;
            SubChildAsk = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();


            /*
            * 正确答案：subChildAnswer
            * 小题数目：TotalItemCount
            * 小题答案：smallSubChileAnswer[i]
            * */
            subChildAnswer = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnswer();
            TotalItemCount = Control.backSum(subChildAnswer,"$、")+1;
            smallSubChileAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                smallSubChileAnswer[i] = Control.returnArray(subChildAnswer,"$、",2)[i];
                Log.e("smallSubChileAnswer==","==i=="+i+"==Sa=="+smallSubChileAnswer[i]);
            }

              /*
            * 学生答案：subChildStuAnswer
            * 小题学生答案：smallSubChileStuAnswer[i]
            * */
            subChildStuAnswer = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildStuAnswer();

            smallSubChileStuAnswer = new String[TotalItemCount];
            for(int i=0;i<TotalItemCount;i++){
                if(subChildStuAnswer.equals("")){
                    smallSubChileStuAnswer[i] = "";
                }else {
                    smallSubChileStuAnswer[i] = Control.returnArray(subChildStuAnswer, "$、", 2)[i];
                }
                Log.e("smallSubChileStuAnswer=","==i=="+i+"==Sa=="+smallSubChileStuAnswer[i]);
            }


            /*
            * 选项个数：sumOption
            * 选项题号：optionIndex[i]
            * 选项内容：optionContent[i]
            * */
            sumOption = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().size();
            optionIndex = new String[sumOption];
            optionContent = new String[sumOption];
            for (int i = 0; i < sumOption; i++) {
                optionIndex[i] = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionIndex();
                optionContent[i] = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildOptionList().get(i).getOptionContent();
            }

            /*
            * 题材类型：ResTypeName
            * */
            GenreName =  mEntityLstjt.get(PaperID).getTKQue().getGenreName();

            /*
            * 文本内容：词汇填空
            * */
            subChildAsk = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAsk();

            String arraySubChildAsk[] = new String[TotalItemCount + 1];
            String subChildAskAll = "";
            for (int i = 0; i < TotalItemCount + 1; i++) {
                arraySubChildAsk[i] = Control.returnArray(subChildAsk, "____", 4)[i];
                if (i < TotalItemCount) {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
                } else {
                    subChildAskAll = subChildAskAll + arraySubChildAsk[i];
                }
            }
            subChildAsk = StringEscapeUtils.unescapeXml(subChildAskAll);

            /*
            * 答案解析：analysis
            **/
            analysis = mEntityLstjt.get(PaperID).getTKQue().getChildList().get(0).getSubChildList().get(0).getSubChildAnalyze();

        }


        String arrayTheme[] = new String[totalItemCount + 1];
        String themeAll = "";
        for (int i = 0; i < totalItemCount + 1; i++) {
            arrayTheme[i] = Control.returnArray(SubChildAsk, "____", 4)[i];
            if (i < totalItemCount) {
                themeAll = themeAll + arrayTheme[i] + "<font color='#3399cc'><middle><middle><U>" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + "（" + (i + 1) + "）" + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</U></middle></middle></font>";
            } else {
                themeAll = themeAll + arrayTheme[i];
            }
        }
        SubChildAsk = StringEscapeUtils.unescapeXml(themeAll);

    }


    /*
    * 获取题目题干信息
    * */
    private void showQuesInfor(){
        holder.WvTheme.loadDataWithBaseURL("about:blank",SubChildAsk,"text/html","utf-8",null);
        holder.WvTheme.getSettings().setDefaultFontSize(18);
        holder.WvTheme.setFocusable(false);

    }
}